// FtpConnection.h: interface for the CFtpConnection class.
// This class deal with the connection and commands with ftp
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_FTPCONNECTION_H__B19697D6_8DD5_4E50_A740_11DBAAE6B598__INCLUDED_)
#define AFX_FTPCONNECTION_H__B19697D6_8DD5_4E50_A740_11DBAAE6B598__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <string>

using namespace std;

class CSocketConnection;

class CFtpConnection 
{
public:
	CFtpConnection(CSocketConnection *pSocket);
	virtual ~CFtpConnection();
	void Connect(string ip, UINT port, string username, string password);
	void ChangeCurrentDir(string dir);
	void ListCurrentDir(char* dirBuf, int bufLen);
	void GetCurrentDir(char* dirBuf, int bufLen);
	void DownloadFile(string filename);
	void DownloadFile(string filename, FILE* pTargetFile);
	unsigned long long GetFileSize(string filename);
	void OnTransferComplete();

private:
	CSocketConnection* m_pSocket;
	BOOL m_bConnected;

private:
	void AddEndChar(char* pBuffer, int len);	//Helper function
	string GetCode(string str);
	void ParsePasvString(const char* buf, string* ip, string* port);

//public:
//    unsigned int currentFilePos;
//    FILE *globalFile;
//    unsigned int FilePos;
//	unsigned int perFilePos;
//	bool CreateNewFile(string fileName, unsigned long long size);
//	unsigned long long fileSize;
	
};
#endif // !defined(AFX_FTPCONNECTION_H__B19697D6_8DD5_4E50_A740_11DBAAE6B598__INCLUDED_)
